/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MrSudokuSaveBox.java
 *
 * Created on 30.08.2011, 18:46:48
 */
package mrsudoku;

import java.io.File;
import javax.swing.JFileChooser;

/**
 *
 * @author flasheater
 */
public class MrSudokuSaveBox extends javax.swing.JDialog {

    /** Creates new form MrSudokuSaveBox */
    public MrSudokuSaveBox(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();


        jFileChooser1.setFileFilter(new SDFileFilter());
        

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFileChooser1 = new javax.swing.JFileChooser();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(mrsudoku.MrSudokuApp.class).getContext().getResourceMap(MrSudokuSaveBox.class);
        jFileChooser1.setDialogTitle(resourceMap.getString("jFileChooser1.dialogTitle")); // NOI18N
        jFileChooser1.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
        jFileChooser1.setFileHidingEnabled(true);
        jFileChooser1.setName("jFileChooser1"); // NOI18N
        jFileChooser1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFileChooser1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jFileChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, 720, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jFileChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, 507, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed
// TODO status message updaten:


    if (evt.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
        File file = jFileChooser1.getSelectedFile();
        
        
        


        //System.out.println(file.getAbsolutePath());
        // hier wird die datei an die logik weitergereicht zum speichern
       
        
        
        MrSudokuApp.getApplication().save(file);


    } else {
        // todo update statusbar
        System.out.println("File access cancelled by user.");

    }
    this.dispose();

}//GEN-LAST:event_jFileChooser1ActionPerformed
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFileChooser jFileChooser1;
    // End of variables declaration//GEN-END:variables
}
